package org.example.bigdata.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.bigdata.service.MissionService;
import org.example.bigdata.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/mission")
public class MissionController {

    @Autowired
    private MissionService missionService;

    /**
     * 获得任务信息
     * @param token
     * @return
     */
    @GetMapping("/fetchMissions")
    public Result fetchMission(@RequestHeader String token){
        return missionService.fetchMission(token);
    }

    /**
     * 提交任务，修改完成状态
     * @param token
     * @param mission_ids
     * @return
     */
    @PutMapping("/submitMission")
    @Transactional
    public Result submitMission(@RequestHeader String token, @RequestBody List<Integer> mission_ids){
        return missionService.submitMission(token,mission_ids);
    }

    @GetMapping("/fetchConclusion")
    public Result fetchConclusion(@RequestHeader String token){
        return missionService.fetchConclusion(token);
    }

    @GetMapping("/fetchGrowth")
    public Result fetchGrowth(@RequestHeader String token){
        return missionService.fetchGrowth(token);
    }


}
